project(RoboCar)
message(STATUS "Author:Pulsar-V")
message(STATUS "Version:1.0.1")
cmake_minimum_required(VERSION 3.0)
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
    set(TORCH_ROOT "E:/packages/libtorch-win-shared-with-deps-1.7.1+cu101/libtorch/share/cmake/Torch")
    set(BOOST_ROOT "F:/PCL 1.10.0/3rdParty/Boost")
    set(Boost_INCLUDE_DIR "F:/PCL 1.10.0/3rdParty/Boost/include/boost-1_72")
    #TODO:OpenCV的位置
    set(OpenCV_DIR E:/packages/opencv-4.5.1/build)
    set(PCL_DIR "F:/PCL 1.10.0/cmake")
    set(PCL_ROOT "F:/PCL 1.10.0")
    set(PYTHON_INCLUDE_DIR "D:/Python36/include")
    set(PYTHON_LIBRARY_DIR "D:/Python36/libs")
    add_definitions(-D _WIN32)
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
    add_definitions(-D __linux__)
    set(THIRD_PACKAGES_DIR /home/pulsar/workspace/packages)
    set(OPENVINO_DIR /opt/intel//openvino_2021.2.185)
    set(OpenCV_DIR ${OPENVINO_DIR}/opencv/cmake)
    set(TBB_DIR ${OPENVINO_DIR}/deployment_tools/inference_engine/external/tbb/cmake)
    set(InferenceEngine_DIR ${OPENVINO_DIR}/deployment_tools/inference_engine/share)
    set(realsense2_DIR ${THIRD_PACKAGES_DIR}/librealsense/lib/cmake/realsense2)
    set(Ceres_DIR ${THIRD_PACKAGES_DIR}/ceres-solver/lib/cmake/Ceres)
    set(absl_DIR ${THIRD_PACKAGES_DIR}/abseil-cpp/lib/cmake/absl)
    set(cartographer_DIR ${THIRD_PACKAGES_DIR}/cartographer/share/cartographer)
endif ()

message(STATUS "Boost_COMPILER:${Boost_COMPILER}")

option(WITH_CONTROL_CENTER "Build Robot Control Center" ON)
set(BOOST_ROOT)
#TODO:是否编译OPENVINO
option(WITH_OPENVINO "Build With OpenVino" OFF)
#TODO:是否编译TBB
option(WITH_TBB "Build With TBB" ON)
set(WITH_TBB ON)
#TODO:是否编译CARTOGRAPHER
option(WITH_CARTOGRAPHER "Build With CARTOGRAPHER" ON)
#TODO:是否编译REALSENSE
option(WITH_LIBREALSENCE2 "Build With Librealsence" ON)
set(WITH_LIBREALSENCE2 ON)
#TODO:编译测试
option(RC_TEST "Build With test" ON)

#有OpenVino一定有TBB
if (${WITH_OPENVINO} STREQUAL "ON")
    set(WITH_TBB ON)
endif ()

#TODO:开启下位控制器模式
#add_definitions(-D USE_DSP_DEVICE)

include(CheckCXXCompilerFlag)
set(CMAKE_CXX_STANDARD 17)

set(ENV_CMAKE_FILES_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(RC_CLIENT_CMAKE_FILES_PATH ${PROJECT_SOURCE_DIR}/robot_client/cmake)
set(RC_SOURCE_DIR ${PROJECT_SOURCE_DIR})
set(RC_BINARY_DIR ${PROJECT_BINARY_DIR})

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
set(OpenGL_GL_PREFERENCE GLVND)
set(BUILD_EXAMPLES OFF)
set(ROBOCAR_APPLICATION_DIR ${PROJECT_SOURCE_DIR}/tools)
set(ROBOCAR_APPLICATION_NAME
        cleargpio
        robocar
        )

set(RC_RESOURCE_DIR ${PROJECT_SOURCE_DIR}/resource)
set(RC_CLIENT_SOURCES_DIR ${PROJECT_SOURCE_DIR}/robot_client/sources)
set(RC_CLIENT_DIR ${PROJECT_SOURCE_DIR}/robot_client)
set(RC_CLIENT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/robot_client/include)

set(ENV_CMAKE_FILES_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_FILES_PATH ${PROJECT_SOURCE_DIR}/src/cmake)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/pistache/subprojects/hinnant-date/include)
include_directories(${PROJECT_SOURCE_DIR}/3rdparty/pistache/subprojects/cpp-httplib/include)

add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/pistache)
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/libserv)
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/websocketpp)
add_subdirectory(robot_client)
add_subdirectory(plugins)
add_subdirectory(test)
add_subdirectory(tools)

if (${WITH_CONTROL_CENTER} STREQUAL "OFF")
    add_subdirectory(robot_center)
endif ()

